/*
 * @lc app=leetcode.cn id=70 lang=java
 *
 * [70] 爬楼梯
 */

// @lc code=start
class Solution {
    public int climbStairs(int n) {
        //solution 1
        /*
        if ( n <= 2)
            return n;
        else 
            return climbStairs(n-1) + climbStairs(n-2);
        */
        if( n <= 2)
            return n;
            
        int[] a = {1,2,3};

        for(int i = 3; i <= n; i++)
        {
            a[2] = a[1] + a[0];
            a[0] = a[1];
            a[1] = a[2];
        }
        return a[2];
    }
}
// @lc code=end

